package com.action.library;

import com.bean.library.Paper;
import com.bean.library.UserPaper;
import com.dao.DaoManager;
import com.dao.library.PaperDao;
import com.dao.library.PaperDaoImpl;

public class GeneratePaperAction {
	public Paper generatePaper(int paperId){
		DaoManager dm = DaoManager.getInstance();
		PaperDao paperDao = dm.getDao(PaperDao.class);
		Paper paper=null;
		try
		{
			dm.begin();
			paper = paperDao.getPaperByPaperId(paperId);
//			Integer[] problemCountEachDifficulty = new Integer[6];
//			problemCountEachDifficulty[1] = 100;
//			problemCountEachDifficulty[2] = 100;
//			problemCountEachDifficulty[3] = 100;
//			problemCountEachDifficulty[4] = 100;
//			problemCountEachDifficulty[5] = 100;
//			paper = paperDao.getPaperRandomly("304032030", problemCountEachDifficulty);
			dm.commit();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally 
		{
			dm.end();
		}
		return paper;
	}
	
	public Paper generateStandardPaper(int paperId){
		DaoManager dm = DaoManager.getInstance();
		PaperDao paperDao = dm.getDao(PaperDao.class);
		UserPaper paper=null;
		try
		{
			dm.begin();
			paper = paperDao.getStandadPaperById(paperId);
			dm.commit();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally 
		{
			dm.end();
		}
		return paper;
	}
}
